﻿<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page isELIgnored="false" %> 

<%@ page import="net.ssta.core.db.RecordSet"%>
<%@ page import="net.ssta.core.db.Record"%>
<%@page import="net.ssta.core.web.RequestKit"%>
<%@ page import="net.ssta.core.db.PagingInfo"%>

<%
	String path = request.getContextPath();
	//分页参数
    PagingInfo pagingInfo =(PagingInfo) request.getAttribute("pagingInfo");
    int pageno = pagingInfo.getCurrentPageNo();
    
    Record searchRcd = (Record) request.getAttribute("searchRcd");
    
    //科技成果信息列表
    RecordSet unitInfoSet = (RecordSet) request.getAttribute("unitInfoSet");
    
    //性别
    RecordSet sex = (RecordSet) request.getAttribute("sex");
    
    //性别
    RecordSet provinceSet = (RecordSet) request.getAttribute("provinceSet");
    
    //代码、值Map
    Map fildOptionMap =  (HashMap)request.getAttribute("fildOptionMap");
    
     //省份代码Map
    Map provinceMap =  (HashMap)request.getAttribute("provinceMap");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<link type="text/css" rel="stylesheet" href="<%=path%>/includes/css/commonStyle.css"/> 
<link type="text/css" rel="stylesheet" href="<%=path%>/includes/styleBase/css/styleBase.css"/>
<link type="text/css" rel="stylesheet" href="<%=path%>/includes/styleBase/css/ostable.css" />
<link type="text/css" rel="stylesheet" href="<%=path%>/includes/styleBase/css/tab.css" />
<link rel="stylesheet" href="<%=path%>/includes/lhgdialog/lhgdialog.css" />



<script type='text/javascript' src="<%=path%>/includes/js/jquery.js"></script>
<script type="text/javascript" src="<%=path%>/includes/styleBase/js/style.js"></script>
<script type="text/javascript" src="<%=path%>/includes/DatePicker/WdatePicker.js"></script>


<script type="text/javascript" src="<%=path%>/includes/lhgdialog/lhgcore.min.js"></script>
<script type="text/javascript" src="<%=path%>/includes/lhgdialog/lhgdialog.js"></script>

<title>科研单位信息推荐</title>
 
<script type="text/javascript">
$("document").ready(function()
{
	 
}); 

function moreSearch()
{
	$('#more').show();
	$('#more1').show();
	$('#moreButton').hide();
	$('#lessButton').show();
}

function lessSearch()
{
	$('#more').hide();
	$('#more1').hide();
	$('#moreButton').show();
	$('#lessButton').hide();
}

function handle()
{
	
	//var length =  $("input[type=checkbox]").length;
	
	var ids= $("input[type='checkbox']");
	var length = 0;
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			length++;
		}
	}
	
	if(length==0)
	{
		alert("请至少一条记录进行操作");
		return;
	}
	
	
	var pids="";
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			pids=pids+ids[i].value+',';  //如果选中，将value添加到变量pids中
		}
	}
	
	var dlg = new J.ui.dialog({ id:'handlekjcgdemand',
		                         title:'处理项目需求',
		                         range:true,
		                         btns:true,
		                         page:'<%=path%>/back/userNeeds/HandleKjcgNeeds.jsp?kjcgUuids='+pids,
		                         width:700,
		                         height:400,
		                         windowObj:window});
	dlg.ShowDialog();
}




function onHandle()
{
	
	//var length =  $("input[type=checkbox]").length;
	
	var ids= $("input[type='checkbox']");
	var length = 0;
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			length++;
		}
	}
	
	if(length==0)
	{
		alert("请至少一条记录进行操作");
		return;
	}
	
	
	var pids="";
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			pids=pids+ids[i].value+',';  //如果选中，将value添加到变量pids中
		}
	}
	
     $.ajax({
			type: "POST", url: "<%=path%>/back/UserNeedsManage?method=unHandKjcgNeeds&kjcgUuids="+pids,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function(msg){
				alert("操作成功!");
				_goPage(<%=pageno%>);
			}
	 });
	
}



function deleteKjcgNeed()
{
	var ids= $("input[type='checkbox']");
	var length = 0;
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			length++;
		}
	}
	
	if(length==0)
	{
		alert("请至少一条记录进行操作");
		return;
	}
	
	
	var pids="";
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			pids=pids+ids[i].value+',';  //如果选中，将value添加到变量pids中
		}
	}
	
	
	$.ajax({
			type: "POST", url: "<%=path%>/back/UserNeedsManage?method=deleteKjcgUserNeeds&kjcgUuids="+pids,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function(msg){
				alert("操作成功!");
				_goPage(<%=pageno%>);
			}
	 });
}





function changeUnitStatus(fieldname,status){
	
	var ids= $("input[type='checkbox']");
	var length = 0;
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			length++;
		}
	}
	
	if(length==0)
	{
		alert("请至少一条记录进行操作");
		return;
	}
	
	
	var pids="";
	for(var i=0; i<ids.length; i++)
	{
		if(ids[i].checked) 
		{
			pids=pids+ids[i].value+',';  //如果选中，将value添加到变量pids中
		}
	}
	
	$.ajax({
			type: "POST", url: "<%=path%>/back/InfoRecommend?method=changeUnitStatus&unitUuids="+pids+"&fieldName="+fieldname+"&status="+status,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function(msg){
				alert("操作成功!");
				_goPage(<%=pageno%>);
			}
	 });
}



function doSearch()
{
	var form = document.getElementById("seaForm");
	form.submit();
}

//跳转
function reloadPage() 
{
	_goPage(<%=pageno%>);
}

function _selectall(){
	var uuids = document.getElementsByName("uuids");
	if(uuids.length){
		for(var i=0;i<uuids.length;i++){
			uuids[i].checked = document.getElementById("selectall").checked;
		}
	}
}


function setSortNum(tableName,uuidFiledName,uuid,sortField,obj){
	//alert(uuid+" sortNum:"+$(obj).val());
	var sortNum = $(obj).val();
	
	for(var i=0; i<sortNum.length; i++) {
		if(sortNum.charCodeAt(i)<48 || sortNum.charCodeAt(i)>57){
             $(obj).val("");
             alert("请输入数字!");
             return;
		}
	}
	
	$.ajax({
			type: "POST", url: "<%=path%>/back/InfoRecommend?method=setSortNum&tableName="+tableName+"&uuidFiledName="+uuidFiledName+"&uuid="+uuid+"&sortField="+sortField+"&sortNum="+sortNum,
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function(msg){
				//alert("操作成功!");
				doSearch();
			}
	 });
}





function viewUnit(unitId,title)
{
	var dlg = new J.ui.dialog(
	{ id:'handledemand',
         title:'科研单位详细信息',
         range:true,
         btns:true,
         page:'<%=path%>/unit/infoForBack.jsp?unitid='+unitId+'&title='+title,
         width:600,
         height:500,
         windowObj:window
       });
	dlg.ShowDialog();
}



</script>

</head>
<body>
<form id="seaForm" name="seaForm" method="post" action="<%=path%>/back/InfoRecommend?method=unitInfoList" >
	<div class="titleDiv">
  <table width="100%" cellpadding="0" cellspacing="0" border="0" style="text-align:left;">
    <tr>
      <td class="box_top_left">&nbsp;</td>
      <td class="box_top_center">科研单位信息推荐</td>
      <td class="box_top_right">&nbsp;</td>
    </tr>
  </table>
</div>
<div class="infoDiv">
  <table border="0" cellpadding="0" cellspacing="0" class="trHeightTable">
    <tr>
      <td class="leftTipArea">单位名称</td>
      <td><input id="keyword" name="keyword" value="<%=searchRcd.getString("KEYWORD","")%>" class="textInput" style="width:100px;"/></td>
      <td class="leftTipArea">所在省市</td>
	  <td>
	      <div class="select"><div><select name="ITEM_64">
		  	   	  <option value="">请选择</option>
				  <%
				  	for(int i=0;i<provinceSet.size();i++){
				  		Record provRecord = provinceSet.get(i);
				  %>
			      		<option <%=searchRcd.getString("ITEM_64","").equals(provRecord.getString("PROVINCE_ID",""))?"selected":""%> value="<%=provRecord.getString("PROVINCE_ID","")%>"><%=provRecord.getString("PROVINCE_NAME","")%></option>
			       <%
			       }
			       %>
           </select></div></div>
      </td>
      <td style="width:30px;"></td>
      <td></td>
      </td>
    </tr>
    <tr>
      <td class="leftTipArea">推荐到频道</td>
      <td >
      	<div>
	      <select name="CHANNELSHOW" id="CHANNELSHOW" style="width:105px;">
		  	   <option value="">请选择</option>
	           <option value="1" <%if("1".equals(searchRcd.getString("CHANNELSHOW"))){%>selected<%}%>>是</option>
	           <option value="0" <%if("0".equals(searchRcd.getString("CHANNELSHOW"))){%>selected<%}%>>否</option>
	      </select>
	      </div>
      </td>
      <td class="leftTipArea">推荐到首页</td>
      <td>
      	<div>
		      <select name="HOMEPAGESHOW" id="HOMEPAGESHOW" style="width:125px;">
			  	   <option value="">请选择</option>
		           <option value="1" <%if("1".equals(searchRcd.getString("HOMEPAGESHOW"))){%>selected<%}%>>是</option>
		           <option value="0" <%if("0".equals(searchRcd.getString("HOMEPAGESHOW"))){%>selected<%}%>>否</option>
		      </select>
	      </div>
      </td>
      <td style="width:30px;"></td>
      <td>
      	<a href="javascript:doSearch();" class="imgButton"><span>查询</span></a>
      </td>
    </tr>
  </table>
</div>

</form>

<div class="titleDiv">
  <table width="100%" cellpadding="0" cellspacing="0" border="0" style="text-align:left;">
    <tr>
      <td class="box_top_left" width="2">&nbsp;</td>
      <td class="box_top_center">查询结果列表</td>
      <td class="box_top_right" width="2">&nbsp;</td>
    </tr>
  </table>
</div>

<div class="contentBox">
    <table class="osTable" cellpadding="0" cellspacing="0" border="0" style="width:100%;">
      <thead>
        <tr >
          <th  width="8%"><input type="checkbox" id="selectall" name="selectall" onclick="javascript:_selectall();" value=""/>选择</th>
          <th  width="15%">单位名称</th>
          <th  width="17%">地址</th>
          <th  width="10%">所在地区</th>
          <th  width="10%">电话</th>
          <th  width="10%">推荐到频道</th>
          <th  width="10%">频道排序号</th>
          <th  width="10%">推荐到首页</th>
          <th  width="10%">首页排序号</th>
        </tr>
      </thead>
      <tbody>
      	<%
      	int i=0;
      	for(i=0;i<unitInfoSet.size();i++){
      		Record unitRecord = unitInfoSet.get(i);
      		String showStr="";
      	%>
	        <tr >
	          <td><input type="checkbox" name="uuids" value="<%=unitRecord.getString("UNITID","")%>"/></td>
	          <td><a href="#2012" onclick="viewUnit('<%=unitRecord.getString("UNITID","")%>','<%=unitRecord.getString("ITEM_9","")%>');"><%=unitRecord.getString("ITEM_9","")%></a></td>
	          <td >
		       	 <%=unitRecord.getString("ITEM_37","")%>	          </td>
	          <td >
	          	 <%=provinceMap.get(unitRecord.getString("ITEM_64",""))==null?"":provinceMap.get(unitRecord.getString("ITEM_64",""))%>	          </td>
	          <td >
	          	 <%=unitRecord.getString("ITEM_39","")%>	          </td>
	          <td >
	             <%=!unitRecord.getString("CHANNELSHOW","").equals("")&&!unitRecord.getString("CHANNELSHOW","").equals("0")?"是":"否"%>
	          </td>
	          <td>
	          		<%if(!unitRecord.getString("CHANNELSHOW","").equals("")&&!unitRecord.getString("CHANNELSHOW","").equals("0")){%>
	          			<input id="CHANNELSORTNUM" name="CHANNELSORTNUM" class="textInput" style="width:40px;" value="<%=unitRecord.getString("CHANNELSORTNUM","")%>" onchange="setSortNum('T_UNIT','UNITID','<%=unitRecord.getString("UNITID","")%>','CHANNELSORTNUM',this)"/>
	          		<%}%>
	          </td>
	          <td >
	             <%=!unitRecord.getString("HOMEPAGESHOW","").equals("")&&!unitRecord.getString("HOMEPAGESHOW","").equals("0")?"是":"否"%>
	          </td>
	          <td>
	          		<%if(!unitRecord.getString("HOMEPAGESHOW","").equals("")&&!unitRecord.getString("HOMEPAGESHOW","").equals("0")){%>
	          			<input id="HOMEPAGESORTNUM" name="HOMEPAGESORTNUM" class="textInput" style="width:40px;" value="<%=unitRecord.getString("HOMEPAGESORTNUM","")%>" onchange="setSortNum('T_UNIT','UNITID','<%=unitRecord.getString("UNITID","")%>','HOMEPAGESORTNUM',this)"/>
	          		<%}%>
	          </td>
	        </tr>
	        <%}
	        
	         for(int j=0;j<pagingInfo.getPageSize()-unitInfoSet.size();j++){ %>
					<tr>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
						<td>&nbsp;</td>
					</tr>
				<%
			}%>
      </tbody>
    </table>
 <div  class="navRightDiv" style="width:100%;text-align:right;padding-right:10px;">
	<jsp:include flush="true" page="/common/paging.jsp"></jsp:include>
</div>
<div class="navDiv">
	    <div class="navLeftDiv">
		    <a href="javascript:changeUnitStatus('CHANNELSHOW','1');" class="imgButton"  ><span>推荐到频道</span></a>
		    <a href="javascript:changeUnitStatus('HOMEPAGESHOW','1');" class="imgButton" ><span>推荐到首页</span></a>
		    
		    <a href="javascript:changeUnitStatus('CHANNELSHOW','0');" class="imgButton" ><span>取消推荐到频道</span></a>
		    <a href="javascript:changeUnitStatus('HOMEPAGESHOW','0');" class="imgButton" ><span>取消推荐到首页</span></a>
	    </div>
	</div>
</div>

</body> 
</html>